package com.xbongbong.saas.model;

import com.xbongbong.paas.domain.entity.PaasFormDataEntity;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.wrap.IModel;
import com.xbongbong.saas.domain.entity.ProductStockEntity;
import com.xbongbong.saas.domain.entity.ProductStockUpdateEntity;

import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;

public interface ProductStockModel extends IModel<ProductStockEntity> {
    /**
     * 根据索引查询数据
     *
     * @param param 查询参数
     * @author Jian.Wang
     * @date 2019/2/21 16:51
     * @since v1.0
     * @return List<ProductEntityExt>
     **/
    @Override
    List<ProductStockEntity> findEntitys(Map<String, Object> param);

    void updateBatch(List<ProductStockEntity> updateList,String corpid) throws XbbException;

    void insertBatch(List<ProductStockEntity> insertList) throws XbbException;

    /**
     * 批次校验
     * @param pageProductIds    产品id
     * @param corpid            公司id
     * @param warehouseId       仓库id
     * @param fieldList         需要查询的字段
     * @param corpid
     * @return
     */
    List<ProductStockEntity> getValidBatchInfoList(List<Long> pageProductIds, String corpid, Long warehouseId, String batch, List<String> fieldList) throws XbbException;
    /**
     * Description: 仓库一致性同步
     * @param corpid
     * @param dataId
     * @param name
     * @return void
     * @author 魏荣杰
     * @date 2019/8/6 10:18
     * @since v1.0
     */
    void dataConsistencyUpdateWarehouse(String corpid, Long dataId, String name);

    /**
     * 更新仓库名称
     *
     * @param updateList
     * @param corpid
     * @throws XbbException
     * @author long.rao
     * @date 2019-08-09 15:47
     */
    void updateBatchWarehouse(List<ProductStockEntity> updateList,String corpid) throws XbbException;

    void deleteByIdIn(String corpid, List<ProductStockEntity> productStockEntityList) throws XbbException;

    List<ProductStockEntity> findEntitysForUpdate(Map<String, Object> map);

    void updateStockDB(Set<String> batchKeyList, Collection<ProductStockUpdateEntity> values, String corpid) throws XbbException;

    List<String> getExistBatchKeyList(String corpid, Set<String> batchKeyList);

    List<ProductStockEntity> getExistBatchEntity(String corpid, Set<Long> parentIdIn);

    List<ProductStockEntity> getHasBatchStockList(Map<String, Object> map);

    List<String> getCorpidExistBatch(List<String> corpidList);

    void updateStockBatch(List<ProductStockEntity> updateProductStockList, String corpid) throws XbbException;

    @Override
    Integer getEntitysCount(Map<String, Object> param);

    List<String> getLatestDistinctBatch(String corpid, String batch);

    /**
     * 获取过期日期范围内的数据
     * @param corpid
     * @param symbol
     * @param timeRange
     * @return
     * @throws XbbException
     */
    List<PaasFormDataEntity> getWithInExpirationDateList(String corpid, String symbol, List<Object> timeRange) throws XbbException;

    /**
     * 根据产品ID和仓库ID查询仓库产品信息
     *
     * @param corpid        公司ID
     * @param productIdIn   产品ID
     * @param warehouseIdIn 仓库ID
     * @return 仓库产品信息
     */
    List<ProductStockEntity> listByProductIdInAndWarehouseIdIn(String corpid, List<Long> productIdIn, List<Long> warehouseIdIn, List<String> batchLsit) throws XbbException;

    /**
     * 根据产品ID和仓库ID查询仓库产品信息
     *
     * @param corpid      公司ID
     * @param productIdIn 产品ID
     * @return 仓库产品信息
     */
    List<ProductStockEntity> listByProductIdIn(String corpid, List<Long> productIdIn, List<Long> warehouseIdIn);

    void updateProductStockById(List<ProductStockEntity> productStockEntityList, String corpid);

    List<ProductStockEntity> getCostIsNullBatchKey(String corpid, List<Long> productIdList);
}
